package com.study.spark.scala.rdd

/**
  * 排序规则
  * @author stephen
  * @create 2019-03-15 14:26
  * @since 1.0.0
  */
object OrderDemo_Implicit_SortRules {

  implicit object OrderingUser extends Ordering[ImplicitUser] {
    override def compare(x: ImplicitUser, y: ImplicitUser): Int = {
      // 先按照分数降序排，分数相同按照年龄升序排
      if(x.score==y.score){
        x.age-y.age
      }else{
        -(x.score-y.score)
      }
    }
  }
}
